import java.util.Scanner;
public class _15 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n =input.nextInt();
        int a[][] = new int[n][n];
        for (int i = 0; i <n; i++) {
            for (int j = 0; j <n; j++) {
                a[i][j] = input.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(i==0&&j>0){  //判断上边界
                    a[i][j]=a[i][j]+a[i][j-1];
                }
                else if(j==0&&i>0){ //判断左边界
                    a[i][j]=a[i][j]+a[i-1][j];
                }
                else if(i>0){ //判断再中间，必选判断
                    a[i][j]=a[i][j]+Math.max(a[i-1][j],a[i][j-1]);
                }
            }
        }
        System.out.println(a[n-1][n-1]);//输出最后一个值
    }
}
